package 策略模式.简单工厂模式加策略模式;

/**
 * 文 件 名 称：Contexts.
 * 文 件 说 明：
 * 创   建   人：zpen.
 * 创 建 时 间：2018/5/4 10:39.
 */
public class Contexts {
    private  Payment payment;

    public Contexts(Payment payment){
        this.payment=payment;
    }
    public Double getTotal(){
         return  payment.getTotals();
    }

    public Contexts(String type,int total,int number){
        switch (type){
            case "d":
                this.payment = new Discount(total*number,0.8);
                break;
            case "n":
                this.payment = new Normal(total*number);
                break;
            case "r":
                this.payment = new Reduce(total*number,500,100);
                break;
        }
    }
}
